package routers

import (
	"dc-news/common/middleware/jwt"
	"dc-news/controller"
	"github.com/gin-gonic/gin"
)

func SetupNewsRouter(r *gin.Engine) {
	v1Group := r.Group("api/v1/news")
	authGroup := v1Group.Group("")
	authGroup.Use(jwt.Auth(false))
	{
		authGroup.GET("list", controller.GetNewsListByChannelHandler)
		authGroup.GET("/:id/info", controller.GetNewsInfoHandler)
		authGroup.GET("/:id/comments", controller.GetNewsCommentsHandler)
		authGroup.GET("/:id", controller.GetNewsHandler)
	}
	mustAuthGroup := v1Group.Group("")
	mustAuthGroup.Use(jwt.Auth(true))
	{
		mustAuthGroup.POST("/:id/favourites", controller.AddFavouriteNewsHandler)
		mustAuthGroup.DELETE("/:id/favourites", controller.RemoveFavouriteNewsHandler)
		mustAuthGroup.POST("channel/likes", controller.AddChannelHandler)
		mustAuthGroup.DELETE("channel/likes", controller.RemoveChannelHandler)
		mustAuthGroup.POST("/:id/likes", controller.LikesNewsHandler)
		mustAuthGroup.DELETE("/:id/likes", controller.CancelLikesNewsHandler)
	}
}
